/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package org.biblio.persistencias;

import java.io.Serializable;
import javax.persistence.*;
import javax.xml.bind.annotation.XmlRootElement;

/**
 *
 * @author Héctor <UFG>
 */
@Entity
@Table(name = "autor_libro", catalog = "mydb", schema = "")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "AutorLibro.findAll", query = "SELECT a FROM AutorLibro a"),
    @NamedQuery(name = "AutorLibro.findByAutlibId", query = "SELECT a FROM AutorLibro a WHERE a.autlibId = :autlibId")})
public class AutorLibro implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = "autlib_id")
    private Integer autlibId;
    @JoinColumn(name = "autlib_id_aut", referencedColumnName = "aut_id", nullable = false)
    @ManyToOne(optional = false)
    private Autor autlibIdAut;
    @JoinColumn(name = "autlib_id_lib", referencedColumnName = "lib_id", nullable = false)
    @ManyToOne(optional = false)
    private Libro autlibIdLib;

    public AutorLibro() {
    }

    public AutorLibro(Integer autlibId) {
        this.autlibId = autlibId;
    }

    public Integer getAutlibId() {
        return autlibId;
    }

    public void setAutlibId(Integer autlibId) {
        this.autlibId = autlibId;
    }

    public Autor getAutlibIdAut() {
        return autlibIdAut;
    }

    public void setAutlibIdAut(Autor autlibIdAut) {
        this.autlibIdAut = autlibIdAut;
    }

    public Libro getAutlibIdLib() {
        return autlibIdLib;
    }

    public void setAutlibIdLib(Libro autlibIdLib) {
        this.autlibIdLib = autlibIdLib;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (autlibId != null ? autlibId.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof AutorLibro)) {
            return false;
        }
        AutorLibro other = (AutorLibro) object;
        if ((this.autlibId == null && other.autlibId != null) || (this.autlibId != null && !this.autlibId.equals(other.autlibId))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return autlibIdAut.getAutApellido() + ", " + autlibIdAut.getAutNombre();
    }
    
}
